<!--  -->
<template>
  <div class="welcome">
    <h2>欢迎XXX进入网站</h2>
    <div id="main" style="width: 1000px; height: 400px"></div>
    <div id="main2" style="width: 600px; height: 400px"></div>
    <div id="main3" style="width: 600px; height: 400px"></div>
    <div id="main4" style="width: 100%; height: 400px"></div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
const echarts = require("echarts");
import { userDelApi } from "../../api/users";
// userDelApi()
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      lession: ["前端", "后端", "全栈", "不会", "不很会", "还行吧"],
    };
  },
  //方法集合
  methods: {
    mainFn() {
      var myChart = echarts.init(document.getElementById("main"));

      // 指定图表的配置项和数据
      var option = {
        title: {
          //标题
          text: "大神",
        },
        tooltip: {},
        legend: {
          data: ["课程"],
        },
        xAxis: {
          data: this.lession,
        },
        yAxis: {},
        series: [
          {
            name: "课程",
            type: "bar",
            data: [5, 20, 100, 10, 10, 20],
          },
        ],
        color: ["#ff5555"],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
    main2Fn() {
      var myChart = echarts.init(document.getElementById("main2"));

      // 指定图表的配置项和数据
      var option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "center",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "40",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
          },
        ],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
    main3Fn() {
      var myChart = echarts.init(document.getElementById("main3"));

      // 指定图表的配置项和数据
      var option = {
        title: {
          text: "Referer of a Website",
          subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
    main4Fn() {
      var myChart = echarts.init(document.getElementById("main4"));

      // 指定图表的配置项和数据
      var option = {
        backgroundColor: "#2c343c",
        title: {
          text: "Customized Pie",
          left: "center",
          top: 20,
          textStyle: {
            color: "#ccc",
          },
        },
        tooltip: {
          trigger: "item",
        },
        visualMap: {
          show: false,
          min: 80,
          max: 600,
          inRange: {
            colorLightness: [0, 1],
          },
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "55%",
            center: ["50%", "50%"],
            data: [
              { value: 335, name: "Direct" },
              { value: 310, name: "Email" },
              { value: 274, name: "Union Ads" },
              { value: 235, name: "Video Ads" },
              { value: 400, name: "Search Engine" },
            ].sort(function (a, b) {
              return a.value - b.value;
            }),
            roseType: "radius",
            label: {
              color: "rgba(255, 255, 255, 0.3)",
            },
            labelLine: {
              lineStyle: {
                color: "rgba(255, 255, 255, 0.3)",
              },
              smooth: 0.2,
              length: 10,
              length2: 20,
            },
            itemStyle: {
              color: "#c23531",
              shadowBlur: 200,
              shadowColor: "rgba(0, 0, 0, 0.5)",
            },
            animationType: "scale",
            animationEasing: "elasticOut",
          },
        ],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
  mounted() {
    this.mainFn();
    this.main2Fn();
    this.main3Fn();
    this.main4Fn();
    userDelApi()
  },
};
</script>
<style lang="less">
.welcome {
  h2 {
    margin-bottom: 20px;
    color: rgb(77, 77, 77);
  }
}
</style>